﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="WebFormEvents.aspx.cs" Inherits="OnlineReservation.WebFormEvents" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder" runat="server">
    <div>
        <asp:UpdatePanel ID="UpdatePanelEvents" runat="server">
            <ContentTemplate>
                All upcoming events:                
                <asp:GridView ID="GridViewEvents" runat="server" ToolTip="Click to by tickets"
                    AutoGenerateColumns="False" DataKeyNames="EventID" AllowPaging="True" PageSize="3"
                    DataSourceID="LinqDataSourceEvents" 
                    onrowdatabound="GridViewEvents_RowDataBound">
                    <Columns>
                        <asp:TemplateField HeaderText="Category">
                            <ItemTemplate>
                                <%# Server.HtmlEncode((string)Eval("Category.CategoryName")) %>
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:BoundField DataField="EventName" HeaderText="Event name"
                            SortExpression="EventName" />
                        <asp:TemplateField HeaderText="Location">
                            <ItemTemplate>
                                <%# Eval("Location.LocationName") %>
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:BoundField DataField="Date" DataFormatString="{0:d}" HeaderText="Date" 
                            SortExpression="Date" />
                        <asp:BoundField DataField="Price" DataFormatString="{0:c}" HeaderText="Price" 
                            SortExpression="Price" />
                    </Columns>
                </asp:GridView> 
                Upcoming events filtered by category: <asp:DropDownList ID="DropDownCategories" runat="server" 
                    AutoPostBack="True" DataSourceID="LinqDataSourceCategories" 
                    DataTextField="CategoryName" DataValueField="CategoryID"></asp:DropDownList>
                <asp:LinqDataSource ID="LinqDataSourceCategories" runat="server" 
                    ContextTypeName="DAOTicketReservationSystem.TicketReservationSystemDataContext" 
                    EntityTypeName="" TableName="Categories">
                </asp:LinqDataSource>
                <asp:GridView ID="GridViewFiltered" runat="server" ToolTip="Click to by tickets"
                    DataKeyNames="EventID" AllowPaging="True" PageSize="1" 
                    AutoGenerateColumns="False" DataSourceID="LinqDataSourceEventsFiltered" 
                    onrowdatabound="GridViewFiltered_RowDataBound">
                    <Columns>
                       <asp:TemplateField HeaderText="Category">
                            <ItemTemplate>
                                <%# Eval("Category.CategoryName") %>
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:BoundField DataField="EventName" HeaderText="Event name"
                            SortExpression="EventName" />
                        <asp:TemplateField HeaderText="Location">
                            <ItemTemplate>
                                <%# Eval("Location.LocationName") %>
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:BoundField DataField="Date" DataFormatString="{0:d}" HeaderText="Date" 
                            SortExpression="Date" />
                        <asp:BoundField DataField="Price" DataFormatString="{0:c}" HeaderText="Price" 
                            SortExpression="Price" />                       
                    </Columns>
                </asp:GridView>
                <asp:LinqDataSource ID="LinqDataSourceEventsFiltered" runat="server" 
                    ContextTypeName="DAOTicketReservationSystem.TicketReservationSystemDataContext" 
                    EntityTypeName="" TableName="Events" 
                    Where="Date &gt; @Date &amp;&amp; CategoryID == @CategoryID">
                    <WhereParameters>
                        <asp:SessionParameter Name="Date" SessionField="Date" Type="DateTime" />
                        <asp:ControlParameter ControlID="DropDownCategories" Name="CategoryID" 
                            PropertyName="SelectedValue" Type="Int32" />
                    </WhereParameters>
                </asp:LinqDataSource>
                <asp:LinqDataSource ID="LinqDataSourceEvents" runat="server" 
                    ContextTypeName="DAOTicketReservationSystem.TicketReservationSystemDataContext" 
                    EntityTypeName="" OrderBy="Date" TableName="Events" Where="Date &gt; @Date">
                    <WhereParameters>
                        <asp:SessionParameter Name="Date" SessionField="Date" Type="DateTime" />
                    </WhereParameters>
                </asp:LinqDataSource>
            </ContentTemplate>
        </asp:UpdatePanel>
    </div>
</asp:Content>
